Ext.define('Inbox.view.inbox.FolderDetail', {
	extend : 'Ext.panel.Panel',
	alias : 'widget.folderDetail',

	border : false,

	initComponent : function() {
		this.display = Ext.create('widget.folderPost', {});
		Ext.apply(this, {
			layout : 'border',
			items : [ this.createGrid(), this.createSouth() ]
		});
		this.relayEvents(this.display, ['opentab']);
		this.relayEvents(this.grid, ['rowdblclick']);
		this.callParent(arguments);
	},

	createGrid : function() {
		this.grid = Ext.create('widget.folderGrid', {
			region : 'center',
			dockedItems : [],
			flex : 2,
			minHeight : 200,
			minWidth : 150,
			listeners : {
				scope : this,
				select : this.onSelect
			}
		});

		this.loadFolder(this.url);
		return this.grid;
	},

	onSelect : function(grid, rec) {
		this.display.setActive(rec);
	},
	
	loadFolder: function(url){
        this.grid.loadFolder(url);
    },
    
    createSouth: function(){
        this.south =  Ext.create('Ext.panel.Panel', {
            layout: 'fit',
            region: 'south',
            border: false,
            split: true,
            flex: 2,
            minHeight: 150,
            items: this.display
        });
        return this.south;
    }

});
